/*
 * Project Name: cms_web
 * File Name: UserCallBackGoodsAction.java
 * Copyright: ZKTeco Corporation 2015
 * Description: TODO 请在此处添加对本文件的描述
 * Creator: Administrator
 * Create Date: 2015年5月12日 上午11:04:36
 */
package com.shishuo.cms.action.manage;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shishuo.cms.auth.AuthPassport;
import com.shishuo.cms.entity.UserCallBackGoods;
import com.shishuo.cms.entity.vo.JsonVo;
@Controller
@RequestMapping("/admin/user")
public class UserCallBackGoodsAction extends AdminBaseAction
{
	@InitBinder("userCallBackGoods")
	public void initBinder(WebDataBinder binder)
	{
		binder.setFieldDefaultPrefix("userCallBackGoods.");
	}
	@AuthPassport
	@RequestMapping(value = "/goods_call_back_list.htm", method = RequestMethod.GET)
	public String goodsCallBackList(@RequestParam(value = "p", defaultValue = "0") int pageNum, ModelMap modelMap) throws Exception
	{
		modelMap.put("pageVo", userCallBackGoodsService.getAllListPage(pageNum, 0));
		return "system/user/goodsCallBackList";
	}

	@AuthPassport
	@RequestMapping(value = {"/updateGoodsCallBackOrder.htm"}, method = RequestMethod.GET)
	public String updateGoodsCallBackOrder(ModelMap modelMap, @RequestParam(value = "id", defaultValue = "0") long id) throws Exception
	{
		UserCallBackGoods userCallBackGoods = userCallBackGoodsService.getById(id);
		modelMap.put("userCallBackGoods", userCallBackGoods);
		return "system/user/updateGoodsCallBackOrder";
	}

	@AuthPassport
	@ResponseBody
	@RequestMapping(value = "/updateGoodsCallBackOrderJson.json", method = RequestMethod.POST)
	public JsonVo<String> updateGoodsCallBackOrderJson(@ModelAttribute UserCallBackGoods userCallBackGoods) throws Exception
	{
		JsonVo<String> json = new JsonVo<String>();
		userCallBackGoodsService.dealCallBackOrder(userCallBackGoods);
		json.setResult(true);
		return json;
	}
}
